home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2808 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.4 KB

  1. Path: wossname.apana.org.au!fjc
  2. Subject: Re: BUG IN "STATUS" COMMAND FOUND
  3. Newsgroups: comp.sys.amiga.programmer
  4. References: <4f403j$qpm@jeack.apana.org.au>
  5. Distribution: world
  6. X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
  7. From: fjc@wossname.apana.org.au (Frank Copeland)
  8. Message-ID: <fjc.2plc@wossname.apana.org.au>
  9. Date: Mon, 5 Feb 96 14:51:35 +1000
  10. Organization: International Oberon Secret Society
  11.  
  12. Brett Eden (brett@jeack.apana.org.au) wrote:
  13. : I have located a bug in the status command, under workbench 3, and it goes
  14. : like this:
  15.  
  16. It happens under KS 2.05 + WB 2.1 too.
  17.  
  18. Just a bit of background first:
  19.  
  20. Every CLI task (off-hand I'm not certain what qualifies a task to be a CLI
  21. task, but running it from a CLI would be favourite) has a unique
  22. identifier, stored in the pr_TaskNum field of its Process structure. This
  23. is an index into a table of ProcessId's which is stored in dos.library's
  24. base structure. This field is defined as a LONG, which is a *signed* 32-bit
  25. integer. It's maximum value is therefore 2^31-1, which just happens to be
  26. 2147483647. The minimum legal value for a CLI is 1 (0 is reserved to
  27. indicate a non-CLI process), but a signed integer can have a minimum value
  28. of -2^31, or -2147483648. Remember these numbers.
  29.  
  30. : 7. System:> Status 2147483647
  31. :
  32. : Causes the shell from which the command was initiated, to freeze, until a ^C
  33. : is issued.
  34.  
  35. This *should* be a legal CLI number, in fact the highest possible CLI
  36. number. Perhaps it is a 'magic' number and has some undocumented
  37. significance to the system which throws the STATUS command into a fit.
  38. Congratulations, you've found a bug :-).
  39.  
  40. : 7. System:> Status 2147483648
  41. :
  42. : Returns an error "Process -2147483648 does not exist" - which, obviously,
  43. : is true, but where did it get the negative sign from?
  44.  
  45. Remember that the CLI number is a *signed* integer. 2147483648 is 2^31,
  46. which is beyond the range of signed integers. However, its valid as an
  47. *unsigned* integer and the bit pattern for unsigned 2147483648 is the same
  48. as for signed -2147483648. What I suspect is happening here is that the
  49. ReadArgs() function (which is a dos.library function used to parse command
  50. lines) is reading the argument as an unsigned integer then converting it to
  51. a signed integer. Actually, its more likely to be simply re-interpreting
  52. the bit pattern as signed.
  53.  
  54. : 7. System:> Status 2147483649
  55. :
  56. : Returns an error "Process -2147483647 does not exist" - which again is true,
  57. : but -2147483647 wasn't the number I entered, was it?
  58.  
  59. Same as above.
  60.  
  61. : 7. System:> Status 2147483650
  62. :
  63. : Returns an error "Bad number" which indicates to us that 2147483649 is
  64. : the ceiling value.
  65.  
  66. Now *this* is somewhat weird. Why call this a bad number and not the
  67. previous two which are also out of range for signed integers? If my theory
  68. is correct, and ReadArgs() is reading numeric arguments as unsigned before
  69. converting them to signed, then this suggests that whoever wrote ReadArgs()
  70. has used the wrong value for the maximum value of a signed integer.
  71.  
  72. : I know this bug plays no trouble in the workings of the system, but it's
  73. : a bug nonetheless, and will give Escom/AmiTech something to do =)
  74.  
  75. If you had 1000 bug reports, and had to allocate a priority level to each
  76. one, what priority would you give this one? Put it another way: don't
  77. expect to see this bug fixed any time soon, if ever :-).
  78.  
  79. Frank Copeland
  80. --
  81. MODULE Sig;
  82. (* $Author: Frank Copeland <fjc@wossname.apana.org.au> $ *)
  83. IMPORT StdDisclaimer, CleverQuote, AdvocateOberon;
  84. END Sig.
  85.